<template>
  <div>
    <router-view v-if="$route.name !=='case'"></router-view>
	  <div v-else class="news-box">
        <h1>{{ $t("page.case.title") }}</h1>
        <div class="content">
          <div class="part" v-for="item,index in curList" :key="index" :class="{reverse:index % 2 !== 0 }">
            <div class="img-part"><img :src="item.imgUrl" alt=""></div>
            <div class="desc-part">
              <h2><router-link :to="{path:'/case/caseDetail',query:{id:index+1}}">{{ item.title }}</router-link></h2>
              <p>{{ item.desc }}</p>
            </div>
          </div>
        </div>
        <div class="block">
          <el-pagination
            background
            @current-change="handleCurrentChange"
            :current-page.sync="currentPage"
            :page-size="pageSize"
            layout="prev, pager, next, jumper"
            :total="total">
          </el-pagination>
        </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      total: 0,
      currentPage: 1,
      pageTotal: "",
      pageSize: 4,
      curList: []
    };
  },
  mounted() {
    this.handleCurrentChange(this.currentPage);
  },
  methods: {
    handleCurrentChange(val) {
      this.total = this.$t("page.case.cList").length;
      this.currentPage = val;
      this.curList = this.$t("page.case.cList").slice(
        (this.currentPage - 1) * this.pageSize,
        this.currentPage * this.pageSize
      );
    }
  }
};
</script>
<style>
.news-box {
  background: #f7f7f7;
  padding-bottom: 30px;
}
.news-box h1 {
  width: 120px;
  margin: 63px auto 40px;
  position: relative;
}
.news-box h1:before {
  content: "";
  display: block;
  position: absolute;
  top: 20px;
  left: -60px;
  width: 40px;
  height: 1px;
  color: #4b96ff;
  background: rgba(75, 150, 255, 1);
}
.news-box h1:after {
  content: "";
  display: block;
  position: absolute;
  top: 20px;
  right: -60px;
  width: 40px;
  height: 1px;
  color: #4b96ff;
  background: rgba(75, 150, 255, 1);
}
.news-box .content {
  width: 1200px;
  margin: 0 auto 40px;
  min-height: 510px;
}
.news-box .part {
  margin: 0 auto 44px;
  display: -ms-flexbox;
  display: flex;
  width: 1180px;
  height: 289px;
  padding: 35px 30px;
  background: rgba(255, 255, 255, 1);
  border-radius: 10px;
  box-shadow: 0px 16px 18px 0px rgba(216, 216, 216, 0.5);
}
.news-box .part.reverse {
  flex-direction: row-reverse;
}
.news-box .part .img-part {
  width: 370px;
  height: 220px;
  margin-right: 38px;
  -ms-flex-align: center;
  align-items: center;
  -ms-flex-pack: center;
  justify-content: center;
  overflow: hidden;
}
.news-box .part.reverse .img-part {
  margin-right: 0;
  margin-left: 38px;
}
.news-box .part .img-part img {
  width: 370px;
  height: 220px;
}
.news-box .part .desc-part {
  text-align: left;
  -ms-flex: 1;
  flex: 1;
}
.news-box .part .desc-part h2 {
  font-size: 24px;
  margin-bottom: 20px;
  margin-top: 33px;
  cursor: pointer;
  font-weight: bold;
}
.news-box .part .desc-part p {
  font-size: 16px;
  line-height: 28px;
}
.news-box .el-pagination {
  margin-top: 30px;
}
</style>
